package com.forum.module.blog.convert.comment;

import com.forum.framework.common.util.colletion.CollectionUtils;
import com.forum.framework.common.util.object.BeanUtils;
import com.forum.module.blog.controller.comment.vo.CommentRespVO;
import com.forum.module.blog.dal.dataobject.comment.CommentDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface CommentConvert {
    CommentConvert INSTANCE = Mappers.getMapper(CommentConvert.class);

    default List<CommentRespVO> covertList(List<CommentDO> list) {
        return CollectionUtils.convertList(list, this::covert);
    }

    default CommentRespVO covert(CommentDO commentDO) {
        return BeanUtils.toBean(commentDO, CommentRespVO.class);
    }
}
